1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to encoding and decoding an image, and more particularly, to encoding an image capable of improving compression efficiency of the image by compensating for a loss due to quantization of a residual block in a frequency domain, and decoding the image.
2. Description of the Related Art
In image compression methods such as Moving Picture Experts Group-1 (MPEG-1), MPEG-2, MPEG-4, and H.264/MPEG-4 Advanced Video Coding (AVC), a prediction image is generated with respect to an input image through inter-prediction and intra-prediction. Then, a residual, which is a difference value between the prediction image and the input image, is transformed, quantized and variable length coded, thereby generating a bitstream.
In intra-prediction, a prediction value for a current block to be encoded is calculated using pixel values of pixels that are spatially adjacent to the current block, and a difference between the prediction value and an actual pixel value of the current block is encoded. In inter-prediction, a motion vector is generated by searching for a region that is similar to the current encoded block in at least one reference picture that precedes or follows the current encoded picture and a differential value between a prediction block generated by motion compensation using the generated motion vector and the current block is encoded.
The transformation process is to transform image data into the frequency domain so as to remove redundancies existing in the residual, which is a difference value between the prediction image and the input image. Examples of the transformation include Discrete Cosine Transform (DCT) and Wavelet Transformation.
The quantization process reduces transformed coefficients generated in the transformation process into significant numbers of bits. When the quantization process is applied, the transformed coefficients can be represented using a smaller number of bits and thus compression efficiency of the image increases. However, since the number of bits is reduced by the quantization process, data may be damaged, compared to the original data. All lossy compression techniques include the quantization process and thus, the original data cannot be completely restored. However, compression efficiency of the data can be increased by performing the quantization process.